﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSharp1.Core;
using System.Collections;
using Weather.Core;

namespace ClassDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            WeatherAPI api = new WeatherAPI("成都");
            WeatherData w = api.GetCityWeatherData();
            
            Console.Read();

        }

        /// <summary>
        /// 集合的使用
        /// </summary>
        private static void TestArrayList()
        {
            //创建对象
            ArrayList list = new ArrayList();
            People p = new People("小花花", "女");
            list.Add(p);//添加数据到集合,末尾 ==> 下标1
            list.Add(new People("小明", "男"));
            list.Add(new People("小红", "女"));
            //集合的长度
            Console.WriteLine("集合的长度为:" + list.Count);
            Console.WriteLine("---------------遍历集合-----------------");
            for (int i = 0; i < list.Count; i++)
            {
                People pp = (People)list[i];
                Console.WriteLine("{0}.姓名:{1} 性别:{2}", i, pp.Name, pp.Sex);
            }
            Console.WriteLine("----foreach---");
            foreach (object item in list)
            {
                People pp = (People)item;
                Console.WriteLine("姓名:{0} 性别:{1}", pp.Name, pp.Sex);
            }
        }


        /// <summary>
        /// 对象创建时必须给数据测试
        /// </summary>
        private static void TestClassInstanceData1()
        {
            //创建实例时给参数
            People p = new People("小花花", "女");
            p.Info();

        }
        /// <summary>
        /// 对象数据测试
        /// </summary>
        private static void TestClassInstanceData()
        {
            //创建(实例化)对象
            Person xiaoming = new Person()
            {
                Age = 10,
                Sex = "女"
            };//对象初始化器:在创建对象时即给属性赋值

            //给对象的属性赋值
            xiaoming.Name = "小红";
            xiaoming.Info();
        }

        private static void TestPersonProperty()
        {
            Person xiaohong = new Person();
            xiaohong.Name = "小明"; //赋值
            string myName = xiaohong.Name;//获取值

            xiaohong.Sex = "男";
            //xiaohong.Height = -100; //错误哦,属性没有setter写入器，无法赋值
            int myHeight = xiaohong.Height;//获取值

            xiaohong.Age = 18;//赋值
            //int myAge = xiaohong.Age;//错误，属性没有getter读取器，无法获取值
            xiaohong.Weight = -100;

            xiaohong.Info();
        }
    }
}
